

cc.Class({
    extends: cc.Component,

    properties: {
        level1Sprite: cc.SpriteFrame,
        level2Sprite: cc.SpriteFrame,
        level3Sprite: cc.SpriteFrame,
    },

    updateLifeCount(lifeCount) {
        this.lifeCount = lifeCount;
        this.light(lifeCount);
    },

    getLifeCount() {
        return this.lifeCount;
    },

    light(count) {
        switch(count) {
            case 0:
                this.getComponent(cc.Sprite).spriteFrame = null;
                this.getComponent(cc.Animation).stop();
                break;
            case 1:
                this.getComponent(cc.Sprite).spriteFrame = this.level1Sprite;
                this.getComponent(cc.Animation).play("level1");
                break;
            case 2:
                this.getComponent(cc.Sprite).spriteFrame = this.level2Sprite;
                this.getComponent(cc.Animation).play("level2");
                break;
            case 3:
                this.getComponent(cc.Sprite).spriteFrame = this.level3Sprite;
                this.getComponent(cc.Animation).play("level3");
                break;
        }
    },
});
